
let context =null 
const initContext=(vue)=>{
	context = vue;
}

//修改密码
const modifyPwdAsync = async(usercell,authCode,oldPassword,newPassword,token)=>{
	let requrl=`${context.serverUrl}/Account/ChangePwd`;
	let [error, result] = await uni.request({
		url:requrl,
		method:"POST",
		header: {
			'Authorization': token,
			'platform': context.mobileDeviceInfo.platform,
			'uuid': context.mobileDeviceInfo.uuid,
			'model': context.mobileDeviceInfo.model,
		},
		data:{
			UserId:usercell,
			AuthCode:authCode,
			OldPassword:oldPassword,
			NewPassword:newPassword,
		}
	});
	if (!error && result.statusCode == 200) {
		return result.data;
	}
	return null;
}

//发送验证码
const phoneVerificationCodeAsync = async(userPhone)=>{
	let requrl=`${context.serverUrl}/Account/PhoneAuthCode`;
	let [error, result] = await uni.request({
		url:requrl,
		method:"POST",
		data:{
			PhoneId:userPhone,
		}
	});
	if (!error && result.statusCode == 200) {
		return result.data;
	}
	return null;
}


const modifyPwdService = {
	initContext,
	modifyPwdAsync,
	phoneVerificationCodeAsync,
}

export default modifyPwdService